package com.wxy.Exception;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

public class ExceptionHandle implements HandlerExceptionResolver{

	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception ex) {
		// TODO 自动生成的方法存根
		ModelAndView modelAndView=new ModelAndView();
		if(ex instanceof Exception)
			ex.printStackTrace();
			modelAndView.addObject("exception",ex.getMessage());
		modelAndView.setViewName("error");
		return modelAndView;
	}
}
